import { Controller, Get, Post, Body, Param } from "@nestjs/common";
import { DeputyGeneralService } from "../../services/deputy-general.service";
import { 
  DeputyGeneralListResponse, 
  DeputyGeneralDetailInfo, 
  CreateDeputyGeneralRequest,
  GenerateDeputyGeneralResponse 
} from "../../interfaces/deputy-general.interface";

@Controller("deputy-general")
export class DeputyGeneralController {
  constructor(private readonly deputyGeneralService: DeputyGeneralService) {}

  @Get("detail/:id/:playerId")
  async getDeputyDetail(
    @Param("id") id: string,
    @Param("playerId") playerId: string
  ): Promise<DeputyGeneralDetailInfo> {
    return await this.deputyGeneralService.getDeputyDetail(
      parseInt(id),
      parseInt(playerId)
    );
  }

  @Get("list/:playerId")
  async getDeputyList(@Param("playerId") playerId: string): Promise<DeputyGeneralListResponse> {
    return await this.deputyGeneralService.getDeputyList(parseInt(playerId));
  }

  @Post("generate")
  async generateDeputy(@Body() body: CreateDeputyGeneralRequest): Promise<GenerateDeputyGeneralResponse> {
    return await this.deputyGeneralService.generateDeputy(
      body.base_id,
      body.player_id
    );
  }
}
